"""
 @Author: xiangwuxiao
 @Email: xiangwuxiao@tencent.com
 @FileName: 获取clb规划信息.py
 @DateTime: 2024/8/5 15:35
"""
import datetime
import os
import sys

vip_info = {
    "pre": {
        "gamesvr": {
            "protocal" : "tcp",
            "vip": "109.244.154.81",
            "hk_vip": "",
        },
        "lockstepsvr": {
            "protocal" : "udp",
            "vip": "109.244.154.81",
            "hk_vip": "",
        },
        "auxsvr": {
            "protocal" : "https",
            "vip": "109.244.154.81",
            "hk_vip": "",
            "domain": "test-nanjing.osgame.qq.com",
            "select_rsip": "9.150.107.160",
            "vport": 28001,
            "rsport": 6805,
        },
        "dirsvr": {
            "protocal" : "https",
            "vip": "109.244.154.81",
            "hk_vip": "",
            "domain": "test-nanjing.osgame.qq.com",
            "select_rsip": "9.150.107.160",
            "vport": 28000,
            "rsport": 6790,
        }
    },
    "test": {
        "gamesvr": {
            "protocal" : "tcp",
            "vip": "109.244.154.81",
            "hk_vip": "",
        },
        "lockstepsvr": {
            "protocal" : "udp",
            "vip": "109.244.154.81",
            "hk_vip": "",
            "vport": 0,
        },
        "auxsvr": {
            "protocal" : "https",
            "vip": "109.244.154.81",
            "hk_vip": "",
            "domain": "test-nanjing.osgame.qq.com",
            "select_rsip": "30.49.248.62",
            "vport": 15001,
            "rsport": 6805,
        },
        "dirsvr": {
            "protocal" : "https",
            "vip": "109.244.154.81",
            "hk_vip": "",
            "domain": "test-nanjing.osgame.qq.com",
            "select_rsip": "30.49.248.62",
            "vport": 15000,
            "rsport": 6790,
        }

    },
    "press": {
        "gamesvr": {
            "protocal" : "tcp",
            "vip": "109.244.154.81",
            "hk_vip": "",
        },
        "lockstepsvr": {
            "protocal" : "udp",
            "vip": "109.244.154.81",
            "hk_vip": "",
            "vport": 0,
        },
        "auxsvr": {
            "protocal" : "https",
            "vip": "109.244.154.81",
            "hk_vip": "",
            "domain": "test-nanjing.osgame.qq.com",
            "select_rsip": "30.49.248.62",
            "vport": 15001,
            "rsport": 6805,
        },
        "dirsvr": {
            "protocal" : "https",
            "vip": "109.244.154.81",
            "hk_vip": "",
            "domain": "test-nanjing.osgame.qq.com",
            "select_rsip": "30.49.248.62",
            "vport": 15000,
            "rsport": 6790,
        }

    },
    "ce": {
        "gamesvr": {
            "protocal" : "tcp",
            "vip": "109.244.157.129,43.141.128.93,114.221.144.235,117.62.240.148,36.155.206.164,36.155.247.191,116.147.17.57,153.3.150.175",
            "hk_vip": "43.129.2.157,43.159.233.71",
        },
        "lockstepsvr": {
            "protocal" : "udp",
            "vip": "109.244.157.142,43.141.128.166,114.222.114.247,180.102.96.92,36.155.187.196,36.155.233.75,112.86.240.114,153.3.149.232",
            "hk_vip": "129.226.107.174,43.129.2.75",
        },
        "auxsvr": {
            "protocal" : "https",
            "vip": "121.229.88.74,114.222.113.87,36.155.205.143,36.155.236.107,59.83.209.146,153.3.150.49,43.141.128.112,109.244.157.163",
            "hk_vip": "43.129.2.214,129.226.103.198",
            "domain": "extern.osgame.qq.com",
            "select_rsip": "9.150.63.122",
            "vport": 29001,
            "rsport": 6805,
        },
        "dirsvr": {
            "protocal" : "https",
            "vip": "121.229.88.74,114.222.113.87,36.155.205.143,36.155.236.107,59.83.209.146,153.3.150.49,43.141.128.112,109.244.157.163",
            "hk_vip": "43.129.2.214,129.226.103.198",
            "domain": "extern.osgame.qq.com",
            "select_rsip": "11.177.84.216",
            "vport": 29000,
            "rsport": 6790,
        },
        "gcchecksvr": {
            "protocal" : "https",
            "vip": "121.229.88.74,114.222.113.87,36.155.205.143,36.155.236.107,59.83.209.146,153.3.150.49,43.141.128.112,109.244.157.163",
            "hk_vip": "43.129.2.214,129.226.103.198",
            "domain": "extern.osgame.qq.com",
            "select_rsip": "11.177.84.216",
            "vport": 29002,
            "rsport": 8080,
        }
    }
}

def job_fail(msg):
    print("ERROR: %s"%(msg))
    sys.exit(1)

if __name__ == "__main__":
    if len(sys.argv) < 3:
        job_fail("Usage: env func_name")

    env = sys.argv[1]
    func_name = sys.argv[2]

    if env not in vip_info:
        job_fail("env %s not surported"%(env))

    info = vip_info[env]

    if func_name not in info:
        job_fail("func name %s not in env %s"%(func_name, env))

    detail = info[func_name]
    print("<SOPS_VAR>protocal:%s</SOPS_VAR>"%(detail.get("protocal", "")))
    print("<SOPS_VAR>vip:%s</SOPS_VAR>"%(detail.get("vip", "")))
    print("<SOPS_VAR>hk_vip:%s</SOPS_VAR>"%(detail.get("hk_vip", "")))
    print("<SOPS_VAR>domain:%s</SOPS_VAR>"%(detail.get("domain", "")))
    print("<SOPS_VAR>vport:%s</SOPS_VAR>"%(detail.get("vport", "")))
    print("<SOPS_VAR>select_rsip:%s</SOPS_VAR>"%(detail.get("select_rsip", "")))
    print("<SOPS_VAR>rsport:%s</SOPS_VAR>"%(detail.get("rsport", "")))